package com.ruoyi.common.utils;

import com.jlx.distribution.pojo.common.RequestContext;
import org.apache.commons.codec.digest.DigestUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.UUID;

/**
 * Created by stephen.zhang on 17/1/10.
 */
public class RequestContextUtil {
    private static final Logger logger = LoggerFactory.getLogger(RequestContextUtil.class);

    public static RequestContext buildDefaultContext() {
        RequestContext context = new RequestContext();
        context.setVersion("1.0.0");
        long time = System.currentTimeMillis();
        String nonce = UUID.randomUUID().toString().replaceAll("-", "");
//        String key = QConfigUtils.getConfig("default.context.key." + channel, "16868419445b43c5b935c596a528cbdf");
        String cacheKey = "95a51552a1d643d2a2b72917dd315176";
        String sign = DigestUtils.md5Hex(nonce + cacheKey + time);
        context.setTimestamp(time);
        context.setChannel("kuyou");
        context.setSign(sign);
        context.setNonce(nonce);
        return context;
    }
}
